Data frequently changes in the rows of tables of a database management system. Concurrency control (CC) protocols are designed to maintain consistency during these data changes, as well as improve the throughput of a database management system. One way to maintain CC is to maintain a lock on data in a database table when data is being manipulated by one or more threads in the database management system. The lock prevents conflicting operations, such as a read and a write on the same row of a table. Another way to maintain CC is to maintain a snapshot of a table in the database management system, where a snapshot is created at a particular time. The one or more threads may then manipulate data from the same snapshot of the table.
A multi-version concurrency control (MVCC) is a CC mechanism that uses the snapshot mechanism. In the MVCC when a read thread reads a row from a table, the write thread may write to the row in the table without being blocked by the read thread. For example, when a read thread reads the data from a row in a table at the same time as the write thread updates or deletes the data from the row, the read thread will use the old copy of the data in the row. In another example, when the first write thread deletes or updates the data in the row, there is a second write thread that is already using the data in the row, and the first write thread will wait until the second write thread completes before modifying the row. Alternatively, the changes made by the first write thread may be removed or rolled back. Since data constantly changes in table 202, a database management system keeps track of multiple versions without impacting memory space. One way to reduce the memory space occupied by the multiple versions of the data is to implement garbage collection on the MVCC data.
In the drawings, like reference numbers generally indicate identical or similar elements. Additionally, generally, the left-most digit(s) of a reference number identifies the drawing in which the reference number first appears.